export default function CustomPathMap() {
	this.pathMap = {
		'CUSTOM_CIRCLE': {
			d: 'M20 20c-220 4-425-177-448-396-24-185 78-380 247-461 160-80 368-56 501 66 134 118 190 318 128 486-57 167-217 293-393 303-12 1-23 2-35 2z m-5-49c202 7 391-161 407-362 19-178-92-361-262-420-166-61-368-2-468 145-103 144-99 356 18 490 74 90 188 146 305 147z m8-44c-186 6-358-158-361-344-9-169 116-334 283-367 155-33 328 46 397 190 71 140 39 327-83 430-64 57-150 91-236 91z m-2-48c164 4 314-144 311-308 3-152-119-297-272-312-143-19-295 73-336 213-43 134 14 295 138 364 48 28 103 43 159 43z m0-99c-64-115-128-230-192-345 128 0 256 0 384 0-64 115-128 230-192 345z',
			height: 14,
      		width:  21,
		},
		'CUSTOM_SCRIPT': {
			d:"M20 20l-4-2-2-1c-58-35-98-67-125-98-26-31-39-62-40-92 0-60 44-105 83-145 39-40 74-78 78-109 1-16-3-32-20-54-17-22-49-48-99-78l-74-43 458 0 5 3 1 0c53 31 89 60 112 89 23 29 32 59 29 88-6 56-52 97-90 137-39 39-70 76-70 112 0 17 7 37 29 62 21 25 57 55 113 88l0 0 73 43-457 0z m13-46l282 0c-25-19-45-37-60-55-26-31-39-62-39-92-1-60 43-105 82-145 39-40 74-78 78-109 1-16-2-32-20-54-16-21-47-46-94-74l-283 0c20 15 36 30 47 45 23 29 33 59 30 88-6 56-52 97-91 137-38 39-70 76-69 112 0 17 7 37 28 62 21 25 56 53 109 85z m-66-80l0-21 220 0 0 21-220 0z m-9-115l0-22 229 0 0 22-229 0z m104-116l0-21 221 0 0 21-221 0z m31-115l0-22 229 0 0 22-229 0z",
			height: 14,
      		width:  21,
		},
		'MESSAGE':{
			d: "M858.6 617.7c-0.8 3.8-2.2 7.6-4.5 11-25.9 38.4-68.2 61.3-113 61.3H277.9c-44.7 0-87-23-113-61.5-3.6-5.3-5.2-11.4-5.1-17.4-9.5-21.6-10.8-44-10.8-60.1v-340c0-36.3 12.6-69.9 35.5-94.4 23.8-25.5 56.9-39.6 93.4-39.6h463.2c75.1 0 133.9 58.9 133.9 134V550.9c0 24.4-5.6 47.2-16.4 66.8zM741.1 630c17 0 33.5-6.1 46.9-17L646.4 470.6l-83.6-83.8c-3.7-3.7-7.7-6.9-11.8-9.7-29.5-19-69.4-15.6-95.3 10.4l-58 58.2-165.5 168c13.2 10.4 29.2 16.2 45.8 16.2h463.1zM815 211c0-42.2-31.8-74-73.9-74H277.9c-40.6 0-68.9 30.4-68.9 74V549.9l146-146.4 58.1-58.9 0.2-0.2c25.7-25.7 59.8-39.9 96-39.9 28.5 0 55.8 8.8 78.6 25.2 6.3 4.4 12.4 9.5 18 15.2l83.4 83.8 125.7 126c0-1.2 0.1-2.5 0.1-3.7v-340z",
			height: 14,
      		width:  21,
		},
		// 开始
		'START':{
			d:"M512 896C229.228 896 0 666.772 0 384s229.228-512 512-512c282.773 0 512 229.228 512 512S794.772 896 512 896z m0-954.183C267.818-58.183 69.818 139.795 69.818 384c0 244.205 198 442.182 442.182 442.182 244.228 0 442.182-197.977 442.182-442.182S756.228-58.183 512-58.183zM750.545 414.228l-349.09 201.545a34.843 34.843 0 0 1-34.91 0 34.897 34.897 0 0 1-17.454-30.228v-403.09c0-12.478 6.659-24 17.454-30.228A34.85 34.85 0 0 1 384 147.544a34.85 34.85 0 0 1 17.455 4.683l349.09 201.545A34.896 34.896 0 0 1 768 384c0 12.477-6.659 24-17.455 30.228zM418.909 242.921V525.08L663.272 384 418.909 242.921z",
			height: 14,
      		width:  21,
		},
		// 结束
		'END':{
			d:"M678.528 253.696c0-17.6-14.4-32-32-32h-268.992a32 32 0 0 0-32 32V514.304a32 32 0 0 0 32 32h268.992c17.6 0 32-14.4 32-32v-260.608zM1015.552 383.872a502.656 502.656 0 0 1-503.68 503.68 502.208 502.208 0 0 1-356.096-147.264 502.016 502.016 0 0 1-147.328-356.416 500.288 500.288 0 0 1 146.816-356.736 499.584 499.584 0 0 1 356.544-146.688c277.312 2.816 503.744 226.24 503.744 503.424z m-947.968 0a444.288 444.288 0 0 0 444.288 444.544c246.976 0 447.296-200.128 447.296-444.544 0-244.032-200.32-444.416-447.296-444.416a442.304 442.304 0 0 0-444.288 444.416z",
			height: 14,
      		width:  21,
		},
		// 网关
		'GATEWAY':{
			d:"M512 235.7c-10.8 0-14.9 1.2-24.1 5.9l-0.3 0.2-189.2 97.6c-17.3 8.3-28.5 25.9-28.5 45.2 0 19.2 11.2 36.9 28.5 45.2l189.5 97.8c10.8 5.4 18.1 5.9 24.1 5.9s13.3-0.5 24.1-5.9l0.3-0.2 189.5-97.8c17.4-8.8 28.2-26 28.2-45s-10.8-36.2-28.2-45L539 243.1c-9.7-7.4-20-7.4-27-7.4z m-0.3 53.1l0.3-0.1 0.1 0.1 185.6 95.8-185.4 95.7-0.3 0.1-0.3-0.1-185.4-95.7 185.4-95.8z m153.2-333.5H359.1c-48.3 0-87.6 39.3-87.6 87.6v61.2c0 48.3 39.3 87.6 87.6 87.6H665c48.3 0 87.6-39.3 87.6-87.6v-61.2c0-48.3-39.4-87.6-87.7-87.6zM359.1 138.8c-19.1 0-34.7-15.6-34.7-34.7v-61.2c0-19.1 15.6-34.7 34.7-34.7H665c19.1 0 34.7 15.6 34.7 34.7v61.2c0 19.1-15.6 34.7-34.7 34.7H359.1z m0 0M603.7 42.9c-18.4 0-30.6 12.2-30.6 30.6 0 18.4 12.2 30.6 30.6 30.6 18.4 0 30.6-12.2 30.6-30.6 0-18.3-12.2-30.6-30.6-30.6M664.9 577.3H359.1c-48.3 0-87.6 39.3-87.6 87.6v61.2c0 48.3 39.3 87.6 87.6 87.6H665c48.3 0 87.6-39.3 87.6-87.6v-61.2c0-48.3-39.4-87.6-87.7-87.6zM359.1 760.8c-19.1 0-34.7-15.6-34.7-34.7v-61.2c0-19.1 15.6-34.7 34.7-34.7H665c19.1 0 34.7 15.6 34.7 34.7v61.2c0 19.1-15.6 34.7-34.7 34.7H359.1z m0 0M389.6 695.5c0 18.4 12.2 30.6 30.6 30.6 18.4 0 30.6-12.2 30.6-30.6 0-18.4-12.2-30.6-30.6-30.6-18.3 0-30.6 12.3-30.6 30.6M199.1 358.1H90.7c-14.6 0-26.5 11.8-26.5 26.5 0 14.6 11.8 26.5 26.5 26.5h108.5c14.6 0 26.5-11.8 26.5-26.5-0.1-14.7-11.9-26.5-26.6-26.5z m-27.7 310.1H90.7c-14.6 0-26.5 11.8-26.5 26.5 0 14.6 11.8 26.5 26.5 26.5h80.7c14.6 0 26.5-11.8 26.5-26.5-0.1-14.6-11.9-26.5-26.5-26.5z m0 0M90.7 358.1c-14.6 0-26.5 11.8-26.5 26.5V688.7c0 14.6 11.8 26.5 26.5 26.5 14.6 0 26.5-11.8 26.5-26.5v-304.2c-0.1-14.6-11.9-26.4-26.5-26.4z m0 0M170 610.4V777.6l83.6-83.6-83.6-83.6z m0 0M932.7 358.1H824.2c-14.6 0-26.5 11.8-26.5 26.5 0 14.6 11.8 26.5 26.5 26.5h108.5c14.6 0 26.5-11.8 26.5-26.5s-11.9-26.5-26.5-26.5z m0-310.2H852c-14.6 0-26.5 11.8-26.5 26.5 0 14.6 11.8 26.5 26.5 26.5h80.7c14.6 0 26.5-11.8 26.5-26.5 0-14.6-11.9-26.5-26.5-26.5z m0 0M932.7 53.9c-14.6 0-26.5 11.8-26.5 26.5V384.5c0 14.6 11.8 26.5 26.5 26.5 14.6 0 26.5-11.8 26.5-26.5v-304.2c0-14.6-11.9-26.4-26.5-26.4z m0 0M853.3 158.6v-167.2L769.7 75l83.6 83.6z m0 0",
			height: 14,
      		width:  21,
		},
		// 标签
		'TAG':{
			d:"M788.48 266.581333c0 17.066667-5.802667 31.744-17.749333 44.714667L421.205333 660.138667c-12.288 12.288-29.354667 22.869333-49.834667 31.744-21.162667 8.874667-39.936 12.970667-57.002667 12.970667L110.933333 704.853333c-17.066667 0-31.744-6.485333-44.032-18.773333-12.288-12.288-18.773333-26.965333-18.773333-44.032l0-202.752c0-17.066667 4.096-36.522667 12.970667-57.002667 8.874667-21.162667 18.773333-37.546667 31.744-49.834667l349.525333-349.525333c12.288-12.288 26.965333-17.749333 44.032-17.749333 17.066667 0 31.744 5.802667 44.714667 17.749333l239.616 239.616C781.994667 234.837333 788.48 249.514667 788.48 266.581333L788.48 266.581333 788.48 266.581333zM248.490667 503.808c-12.288-12.288-26.965333-18.090667-44.032-18.090667-17.066667 0-31.744 5.802667-44.032 18.090667-12.288 12.288-18.090667 26.965333-18.090667 44.032 0 17.066667 5.802667 31.744 18.090667 44.032 12.288 12.288 26.965333 18.090667 44.032 18.090667 17.066667 0 31.744-5.802667 44.032-18.090667C260.778667 579.584 266.24 564.906667 266.24 547.84 267.264 530.432 260.778667 516.096 248.490667 503.808L248.490667 503.808 248.490667 503.808zM958.122667 311.637333 608.597333 660.138667c-12.288 12.288-29.354667 22.869333-49.834667 31.744C537.6 700.757333 518.826667 704.853333 501.76 704.853333l-109.909333 0c17.066667 0 36.522667-4.096 57.002667-12.970667 21.162667-8.874667 37.546667-18.773333 49.834667-31.744l349.525333-348.501333c12.288-12.970667 18.090667-27.648 18.090667-44.714667s-5.802667-31.744-18.090667-44.032l-229.034667-229.717333c9.898667-9.898667 18.773333-17.066667 25.941333-21.845333 7.168-4.778667 17.066667-6.485333 28.672-6.485333 17.066667 0 31.744 5.802667 44.714667 18.090667l239.616 240.298667c12.288 12.288 17.749333 26.965333 17.749333 44.032S970.069333 298.325333 958.122667 311.637333L958.122667 311.637333 958.122667 311.637333zM958.122667 311.637333",
			height: 14,
      		width:  21,
		},
		// 标签
		'TAG_REMOVE':{
			d:"M491.558 711.027l-10.259-15.87c-4.168-6.572-7.695-15.71-7.534-25.969 0-10.42 3.366-21.32 9.939-32.381 9.618-16.030 26.771-33.022 53.702-50.335l227.15-153.891-2.885 121.67-270.111 156.777zM1149.603 220.179l0.321-0.16c16.030-9.778 30.618-16.191 46.167-17.473s30.458 3.527 43.282 11.221c24.045 14.267 45.686 35.587 53.541 65.885s0.962 65.885-23.084 106.121c-0.16 0.481-0.481 0.962-0.641 1.443-24.045 40.396-56.427 61.556-90.251 65.404-33.984 4.008-66.526-7.053-96.663-21.16-21.32-10.259-36.87-17.954-49.213-20.519-12.343-2.244-21.962-1.763-39.435 6.733l-48.732 28.374 2.244-96.342 202.463-129.525zM1179.098 383.528c41.999-25.488 55.465-79.991 29.977-121.991l-151.967 91.854c25.328 41.999 79.991 55.465 121.991 30.137zM815.531 312.032c-0.802-19.236-4.969-28.053-12.824-37.671-8.175-9.618-22.442-19.557-41.679-33.343-26.771-19.717-52.259-42.961-65.083-74.701-12.985-31.9-9.618-70.854 15.069-111.731 23.725-40.396 51.618-63.64 82.075-71.335 30.297-7.534 59.473 1.122 83.358 15.389 13.145 7.695 24.366 18.435 30.778 32.702 6.252 14.267 7.695 30.137 6.893 48.732l-0.16 0.321-17.633 259.050-1.122 15.389c-0.641 7.855 5.29 14.588 13.145 15.229 1.122 0 2.084-0.16 3.206-0.321h0.481l-6.252 254.241-17.152 170.563c-2.405 32.061-8.977 55.144-18.595 71.335-6.412 11.061-14.427 19.236-23.565 24.206-8.977 4.969-18.595 6.412-26.45 5.771l-18.916-1.282 12.343-497.421 2.084-85.121zM843.103 227.713l6.412-177.456c-49.053-1.763-90.251 36.549-91.854 85.442-1.763 49.053 36.549 90.251 85.442 92.014z",
			height: 14,
      		width:  21,
		},
		// 标签
		'APP':{
			d:"M311.8 726.8L253.6 785C156.4 710.9 92.1 595.8 86 465.6h81.4c6.1 107.8 61.4 202.2 144.4 261.2z m544.8-261.2H938C931.9 595.8 867.6 711 770 785l-58.2-58.2c83.4-59 138.7-153.4 144.8-261.2z m-80.1-20.4c0 124.9-86.7 229.5-203.4 257.1V730c0 33.8-27.3 61-61 61-33.8 0-61-27.3-61-61v-27.7c-116.8-27.7-203.4-132.2-203.4-257.1v-223.8L166.3 140v-40.7H858V140l-81.4 81.4V445.2zM512-22.7c5.7 0 11 0.4 16.3 1.6 26.4 5.3 48.4 23.6 58.6 48 4.1 9.8 6.5 20.3 6.5 31.7H430.6c0-44.7 36.6-81.3 81.4-81.3z m0 0",
			height: 14,
      		width:  21,
		},
	}
	this.getRawPath = function getRawPath(pathId) {
		return this.pathMap[pathId].d;
	};
	this.getScaledPath = function getScaledPath(pathId, param) {
		var rawPath = this.pathMap[pathId];

		// positioning
		// 计算开始绘图的位置
		var mx, my;

		if (param.abspos) {
			mx = param.abspos.x;
			my = param.abspos.y;
		} else {
			mx = param.containerWidth * param.position.mx;
			my = param.containerHeight * param.position.my;
		}

		var coordinates = {}; // map for the scaled coordinates
		if (param.position) {

			// path
			var heightRatio = (param.containerHeight / rawPath.height) * param.yScaleFactor;
			var widthRatio = (param.containerWidth / rawPath.width) * param.xScaleFactor;


			// // Apply height ratio
			// for (var heightIndex = 0; heightIndex < rawPath.heightElements.length; heightIndex++) {
			// 	coordinates['y' + heightIndex] = rawPath.heightElements[heightIndex] * heightRatio;
			// }

			// // Apply width ratio
			// for (var widthIndex = 0; widthIndex < rawPath.widthElements.length; widthIndex++) {
			// 	coordinates['x' + widthIndex] = rawPath.widthElements[widthIndex] * widthRatio;
			// }
		}

		// Apply value to raw path
		var path = format(
			rawPath.d, {
				mx: mx,
				my: my,
				e: coordinates
			}
		);
		return path;
	};
}
var tokenRegex = /\{([^}]+)\}/g,
	objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g; // matches .xxxxx or ["xxxxx"] to run over object properties

function replacer(all, key, obj) {
	var res = obj;
	key.replace(objNotationRegex, function (all, name, quote, quotedName, isFunc) {
		name = name || quotedName;
		if (res) {
			if (name in res) {
				res = res[name];
			}
			typeof res == 'function' && isFunc && (res = res());
		}
	});
	res = (res == null || res == obj ? all : res) + '';

	return res;
}

function format(str, obj) {
	return String(str).replace(tokenRegex, function (all, key) {
		return replacer(all, key, obj);
	});
}